package com.ciwong.epaper.modules.epaper.bean;

import com.ciwong.mobilelib.bean.BaseBean;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class Node extends BaseBean {

    private int id;
    /**
     * 根节点pId为0
     */
    private int pId = 0;

    private CatalogueInfo catalogueInfo;

    private PackageInfo packageInfo;

    private boolean isSuo;

    public int getIsFree() {
        return isFree;
    }

    public void setIsFree(int isFree) {
        this.isFree = isFree;
    }

    /**
     * 是否免费（1:免费 0:收费）
     */
    private int isFree;

    /**
     * 是否加密 0为不加密  1 为加密
     */
    private int isPwd;

    /**
     * 当前的级别
     */
    private int level;


    private boolean isLastItem;


    /**
     * 下一级的子Node
     */
    private List<Node> children = new ArrayList<Node>();

    /**
     * 父Node
     */
    private Node parent;

    public Node() {

    }

    public Node(int id, int pId, CatalogueInfo catalogueInfo, PackageInfo packageInfo) {
        super();
        this.id = id;
        this.pId = pId;
        this.catalogueInfo = catalogueInfo;
        this.packageInfo = packageInfo;
    }

    public Node(int id, PackageInfo packageInfo, boolean isLastItem) {
        this.id = id;
        this.packageInfo = packageInfo;
        this.isLastItem = isLastItem;
    }

    public boolean isLastLevel() {
        return children.size() == 0;
    }

    public void setSuo(boolean suo) {
        isSuo = suo;
    }

    public boolean isSuo() {
        return isSuo;
    }

    public void setCatalogueInfo(CatalogueInfo catalogueInfo) {
        this.catalogueInfo = catalogueInfo;
    }

    public void setPackageInfo(PackageInfo packageInfo) {
        this.packageInfo = packageInfo;
    }

    public CatalogueInfo getCatalogueInfo() {
        return catalogueInfo;
    }

    public PackageInfo getPackageInfo() {
        return packageInfo;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getpId() {
        return pId;
    }

    public void setpId(int pId) {
        this.pId = pId;
    }

    public int getIsPwd() {
        return isPwd;
    }

    public void setIsPwd(int isPwd) {
        this.isPwd = isPwd;
    }

    public void setLevel(int level) {
        this.level = level;
    }


    public List<Node> getChildren() {
        return children;
    }

    public void setChildren(List<Node> children) {
        this.children = children;
    }

    public Node getParent() {
        return parent;
    }

    public void setParent(Node parent) {
        this.parent = parent;
    }

    /**
     * 是否为跟节点
     *
     * @return
     */
    public boolean isRoot() {
        return parent == null;
    }


    /**
     * 是否是叶子界点
     *
     * @return
     */
    public boolean isLeaf() {
        return children.size() == 0;
    }

    /**
     * 获取level
     */
    public int getLevel() {
        return parent == null ? 0 : parent.getLevel() + 1;
    }


    public void setLastItem(boolean lastItem) {
        isLastItem = lastItem;
    }

    public boolean isLastItem() {
        return isLastItem;
    }
}
